﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class Room
    {
        public string ID { get; set; }
        public string RoomID { get; set; }
        public string FloorID { get; set; }
        public string FloorName { get; set; }
        public string EditorUserID { get; set; }
        public string EditorUserName { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public string Status { get; set; }
        public string OrderBy { get; set; }
        public string Timestamp { get; set; }
        public string BackColor { get; set; }

        public Room(DataAccessLayer.Room Room)
        {
            this.ID = Room.ID.ToString();
            this.RoomID = Room.RoomID.ToString();
            this.FloorID = Room.FloorID.ToString();
            this.FloorName = Room.Floor.Name;
            this.EditorUserID = Room.EditorUserID.ToString();
            this.EditorUserName = Room.sUser.Users.Last().Username;
            this.Name = Room.Name;
            this.Description = Room.Description;
            switch ((RoomStatus)Room.RoomStatusID)
            {
                case RoomStatus.Usable:
                    this.Status = "سالم";
                    break;
                case RoomStatus.Unusable:
                    this.Status = "خراب";
                    break;
            }
            this.OrderBy = Room.OrderBy.ToString();
            this.Timestamp = Room.Timestamp.ToHijriSolarString();
            this.BackColor = Room.IsDeleted ? "#FF5555" : "#FFFFFF";
        }

        public static List<Room> Convert(List<DataAccessLayer.Room> Rooms)
        {
            return (Rooms.ConvertAll(new Converter<DataAccessLayer.Room, Room>(p => (new Room(p)))));
        }
    }
}
